package com.trolls.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.TabPanel;

public class CompositeShowItem extends Composite{
	private HorizontalPanel hPanelPrincipal;
	private CompositePortraitUi CompositePortraitUi;
	private TabPanel tPanel;
	private Item itemSelected;
	public CompositeShowItem(Item item){
		itemSelected =item;
		hPanelPrincipal = new HorizontalPanel();
		CompositePortraitUi = new CompositePortraitUi(item.getImagePath(),item.getName());
		tPanel = new TabPanel();
		tPanel.setStyleName("tabPanel");
		tPanel.add(new HTML(), "Histoire");
		tPanel.add(new HTML(), "Caracteristiques");
		tPanel.selectTab(0);
		
		hPanelPrincipal.add(CompositePortraitUi);
		hPanelPrincipal.add(tPanel);
		showItem(item);
		this.initWidget(hPanelPrincipal);

	}
	public void showItem(Item item) {
		itemSelected = item;
		Image img = new Image(item.getImagePath());
		img.addStyleName("gallery-img");
		img.setTitle(item.getName());
		img.setAltText(item.getName());
		
		CompositePortraitUi.setImg(img);
		tPanel.getWidget(0).getElement().setInnerHTML(item.getDescription());
		tPanel.getWidget(1).getElement().setInnerHTML(item.AfficherCaracteristiques());

	}

}
